package com.gljx.web.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.gljx.web.Entity.Oilspec;
import com.gljx.web.dao.CommonDao;
import com.gljx.web.dao.OilspecMapper;
import com.gljx.web.service.OilspecService;

@Transactional
@Service
public class OilspecServiceImpl extends CommonDao implements OilspecService{

	@Autowired
	private OilspecMapper oilspecMapper;
	
	/**
	 * 实现根据控制单元id查询
	 */
	@Override
	public List<Oilspec> queryOilsperByFcontrolunitid(String companyId) {
		// TODO Auto-generated method stub
		return oilspecMapper.selectOilsperByFcontrolunitid(companyId);
	}

	/**
	 * 实现根据控制单元id和规格查询
	 */
	@Override
	public List<Oilspec> queryOilsperByFcontrolunitidAndFnameL2(String companyId,String fnameL2) {
		// TODO Auto-generated method stub
		Map<String, String> map = new HashMap<String, String>();
		map.put("companyId", companyId);
		map.put("fnameL2", fnameL2);
		return oilspecMapper.selectOilsperByFcontrolunitidAndFnameL2(map);
	}

	/**
	 * 实现查询上一个编码
	 */
	@Override
	public String selectFnumber(String companyId) {
		// TODO Auto-generated method stub
		return oilspecMapper.selectFnumber(companyId);
	}

	/**
	 * 实现添加
	 */
	@Override
	public void addOilspec(Oilspec oilspec) {
		// TODO Auto-generated method stub
		oilspecMapper.insertSelective(oilspec);
	}

	/**
	 * 实现删除功能
	 */
	@Override
	public void deleteOilspecByFid(String fid) {
		// TODO Auto-generated method stub
		oilspecMapper.deleteByPrimaryKey(fid);
	}

	/**
	 * 实现根据fid查询
	 */
	@Override
	public Oilspec queryByPrimaryKey(String fid) {
		// TODO Auto-generated method stub
		return oilspecMapper.selectByPrimaryKey(fid);
	}

	/**
	 * 实现修改
	 */
	@Override
	public void modifyOilspec(Oilspec oilspec) {
		// TODO Auto-generated method stub
		oilspecMapper.updateByPrimaryKeySelective(oilspec);
	}

	@Override
	public List<Oilspec> queryOilsperAll() {
		// TODO Auto-generated method stub
		return oilspecMapper.selectOilsperAll();
	}

	@Override
	public List<Oilspec> queryOilsperByName(String fnameL2) {
		// TODO Auto-generated method stub
		return oilspecMapper.selectOilsperByName(fnameL2);
	}

}
